Reuse CelExpressionFlatImpl evaluation state across non-concurrent Evaluate calls. - #2299
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
copybara-service
Bot
force-pushed
the
test_988498326
branch
from
September 29, 2026 01:00
d43c2e2 to
d13c627
Compare
…aluate calls. - `CelExpressionFlatImpl::Evaluate(activation, arena)` reuses a cached `FlatExpressionEvaluatorState` when it is not already in use (claimed via `std::atomic<bool> cached_state_in_use_`). Concurrent callers fall back to the existing per-call `InitializeState` path, so thread safety is unchanged. - The cached state is created on first use with the caller's arena and rebound to the caller's arena on later calls via the new `FlatExpressionEvaluatorState::SetArena()`. It is `Reset()` before being released so no values outlive the call's arena. - This avoids allocating/freeing the evaluator state (value stack, comprehension slots, iterator stack) on every evaluation. PiperOrigin-RevId: 988498326
copybara-service
Bot
force-pushed
the
test_988498326
branch
from
September 29, 2026 02:44
d13c627 to
4be1891
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reuse CelExpressionFlatImpl evaluation state across non-concurrent Evaluate calls.
CelExpressionFlatImpl::Evaluate(activation, arena)reuses a cachedFlatExpressionEvaluatorStatewhen it is not already in use (claimed viastd::atomic<bool> cached_state_in_use_). Concurrent callers fall back tothe existing per-call
InitializeStatepath, so thread safety is unchanged.rebound to the caller's arena on later calls via the new
FlatExpressionEvaluatorState::SetArena(). It isReset()before beingreleased so no values outlive the call's arena.
comprehension slots, iterator stack) on every evaluation.